package net.zabuchy.meeting.entity;

import java.io.Serializable;
import javax.persistence.*;

import net.zabuchy.address.entity.Address;
import net.zabuchy.user.entity.User;

import org.hibernate.annotations.Cascade;

import java.util.Date;
import java.util.Set;

@Entity
@Table(name="meeting", catalog="quickstart")
public class Meeting implements Serializable {
	
	private static final long serialVersionUID = 1L;

	private int meetingId;
	private int customerId;
	private String author;
	private String title;
	private String description;
	private String leading;
	private Date creationDate;
	private Date meetingDate;
	private String meetingTime;
	private int duration;
	private String place;
	private Address address;
	private Set<User> participants;
	

    public Meeting() {
    }
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="MEETING_ID", unique=true, nullable=false)
	public int getMeetingId() {
		return this.meetingId;
	}

	public void setMeetingId(int meetingId) {
		this.meetingId = meetingId;
	}

	@Column(name="CUSTOMER_ID", nullable=false)
	public int getCustomerId() {
		return this.customerId;
	}

	public void setCustomerId(int customerId) {
		this.customerId = customerId;
	}

	@Column(name="AUTHOR")
	public String getAuthor() {
		return author;
	}

	public void setAuthor(String author) {
		this.author = author;
	}
	
	@Column(name="TITLE")
	public String getTitle() {
		return this.title;
	}

	public void setTitle(String title) {
		this.title = title;
	}
	
	@Column(name="DESCRIPTION")
	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Column(name="LEADING_USER")
	public String getLeading() {
		return leading;
	}

	public void setLeading(String leading) {
		this.leading = leading;
	}
	
	@Column(name="CREATION_DATE")
	public Date getCreationDate() {
		return creationDate;
	}

	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}

	@Column(name="MEETING_DATE")
	public Date getMeetingDate() {
		return meetingDate;
	}

	public void setMeetingDate(Date meetingDate) {
		this.meetingDate = meetingDate;
	}

	@Column(name="MEETING_TIME")
	public String getMeetingTime() {
		return meetingTime;
	}

	public void setMeetingTime(String meetingTime) {
		this.meetingTime = meetingTime;
	}

	@Column(name="DURATION")
	public int getDuration() {
		return duration;
	}
	
	public void setDuration(int duration) {
		this.duration = duration;
	}

	@Column(name="PLACE")
	public String getPlace() {
		return place;
	}

	public void setPlace(String place) {
		this.place = place;
	}

	@ManyToOne(fetch=FetchType.EAGER)
	@Cascade(org.hibernate.annotations.CascadeType.SAVE_UPDATE)
	@JoinColumn(name="ADDRESS_ID")
	public Address getAddress() {
		return this.address;
	}

	public void setAddress(Address address) {
		this.address = address;
	}
	
	@ManyToMany(fetch=FetchType.EAGER)
	@Cascade(org.hibernate.annotations.CascadeType.SAVE_UPDATE)
	@JoinTable(
		name="USER_MEETINGS"
		, joinColumns={
			@JoinColumn(name="MEETING_ID")
			}
		, inverseJoinColumns={
			@JoinColumn(name="USER_ID")
			}
		)
	public Set<User> getParticipants() {
		return this.participants;
	}

	public void setParticipants(Set<User> participants) {
		this.participants = participants;
	}
	
}